home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_03
/
8n03106a
< prev
next >
Wrap
Text File
|
1990-03-18
|
1KB
|
48 lines
*****Listing 1*****
date_print3(date)
date date; /* internal date form */
{
static struct datecache {
date internal;
printable_date external;
unsigned inuse : 1;
} dates[MAXDATEPRINTS];
static struct datecache *d_last_used = dates;
static struct datecache *d_last_stored = dates;
/* last one used is highly likely */
struct datecache *d = d_last_used;
do {
if (d->internal == date) {
d_last_used = d;
d->inuse = TRUE;
return(d->external);
}
d = next_date(d);
} while (d != d_last_used);
/* we have moved all the way around the buffer */
/* and didn't find it in cache */
/* find a new buffer */
d = next_date(d_last_stored);
do {
if (d->inuse) d->inuse = FALSE;
else break;
} while (d != d_last_stored);
/* either found one not in use, or all in use */
d->inuse = FALSE; /* nec. if all are in use */
d_last_used = d;
d_last_stored = d;
/* actually do the work and convert date */
/* into a printable representation */
.....
memcpy(d_last_used->external,....);
return(d_last_used->external);
}